import request from '../utils/request'

// 用户页 - 获取用户个人信息
const getUserInfoAPI = () => {
  return request({
    method: 'GET',
    url: '/v1_0/user'
  })
}

// 用户页 - 获取个人基本资料
const getUserProfileAPI = () => {
  return request({
    method: 'GET',
    url: '/v1_0/user/profile'
  })
}

// 用户页 - 更新用户头像
const updateUserPhotoAPI = ({ form }) => {
  return request({
    method: 'PATCH',
    url: '/v1_0/user/photo',
    data: form
  })
}

// 用户页 - 更新用户基本资料
const updateUserProfileAPI = ({ name, birthday }) => {
  return request({
    method: 'PATCH',
    url: '/v1_0/user/profile',
    data: {
      name,
      birthday
    }
  })
}

// 根据 refresh_token 更新 token
const updateTokenAPI = () => {
  return request({
    method: 'PUT',
    url: '/v1_0/authorizations'
  })
}
export {
  getUserInfoAPI,
  getUserProfileAPI,
  updateUserPhotoAPI,
  updateUserProfileAPI,
  updateTokenAPI
}
